import { createResolver, defineNuxtModule } from "nuxt/kit";

export default defineNuxtModule({
  /**
   * 设置 Nuxt 应用的相关配置
   *
   * @param _options - 初始化配置参数，这里不使用
   * @param nuxt - Nuxt 应用实例
   */
  async setup(_options, nuxt) {
    const { resolve } = createResolver(nuxt.options.rootDir);
    nuxt.hook("i18n:registerModule", (registerPluginHooks) => {
      registerPluginHooks({
        langDir: resolve("./assets/i18n"),
        locales: [
          { code: "en", name: "English", file: "en-us.json" },
          { code: "zh", name: "Chinese", file: "zh-cn.json" },
        ],
      });
    });
  },
});
